package com.vcit.clazz.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vcit.common.utils.poi.ExcelUtil;
import com.vcit.system.domain.clazz.TClazz;
import com.vcit.system.service.clazz.ITClazzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vcit.common.annotation.Log;
import com.vcit.common.core.controller.BaseController;
import com.vcit.common.core.domain.AjaxResult;
import com.vcit.common.enums.BusinessType;

import com.vcit.common.core.page.TableDataInfo;

/**
 * 班级Controller
 * 
 * @author dff
 * @date 2025-01-08
 */
@Api("班级信息管理")
@RestController
@RequestMapping("/system/clazz")
public class TClazzController extends BaseController
{
    @Autowired
    private ITClazzService tClazzService;

    /**
     * 查询班级列表
     */
    @ApiOperation("获取班级信息列表")
    @PreAuthorize("@ss.hasPermi('system:clazz:list')")
    @GetMapping("/list")
    public TableDataInfo list(TClazz tClazz)
    {
        startPage();
        List<TClazz> list = tClazzService.selectTClazzList(tClazz);
        return getDataTable(list);
    }
    /**
     * 查询班级列表
     */
    @ApiOperation("获取班级下拉信息列表")
    @GetMapping("/selectlist")
    public List<TClazz> selectlist(TClazz tClazz)
    {

        List<TClazz> list = tClazzService.selectTClazzList(tClazz);
        return list;
    }

    /**
     * 导出班级列表
     */
    @ApiOperation("导出班级信息")
    @PreAuthorize("@ss.hasPermi('system:clazz:export')")
    @Log(title = "班级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TClazz tClazz)
    {
        List<TClazz> list = tClazzService.selectTClazzList(tClazz);
        ExcelUtil<TClazz> util = new ExcelUtil<TClazz>(TClazz.class);
        util.exportExcel(response, list, "班级数据");
    }

    /**
     * 获取班级详细信息
     */
    @ApiOperation("获取班级详细信息")
   // @PreAuthorize("@ss.hasPermi('system:clazz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tClazzService.selectTClazzById(id));
    }

    /**
     * 新增班级
     */
    @ApiOperation("新增班级信息")
    @PreAuthorize("@ss.hasPermi('system:clazz:add')")
    @Log(title = "班级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TClazz tClazz)
    {
        return toAjax(tClazzService.insertTClazz(tClazz));
    }

    /**
     * 修改班级
     */
    @ApiOperation("修改班级信息")
    @PreAuthorize("@ss.hasPermi('system:clazz:edit')")
    @Log(title = "班级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TClazz tClazz)
    {
        return toAjax(tClazzService.updateTClazz(tClazz));
    }

    /**
     * 删除班级
     */
    @ApiOperation("删除班级信息")
    @PreAuthorize("@ss.hasPermi('system:clazz:remove')")
    @Log(title = "班级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tClazzService.deleteTClazzByIds(ids));
    }
}
